You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

jss-plugin-default-unit

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jss-plugin-default-unit

JSS plugin that adds default custom unit to numeric values where needed

10.10.0
latest
Source
npm
Version published
Weekly downloads
2M
2.26%
Maintainers
1
Weekly downloads
 
Created

What is jss-plugin-default-unit?

The jss-plugin-default-unit npm package is a plugin for JSS (JavaScript Style Sheets) that automatically adds units to numeric values in style objects. This is particularly useful when working with CSS in JS, as it simplifies the process of defining styles by allowing developers to omit units for properties that require them, with the plugin automatically appending the appropriate unit based on the property.

What are jss-plugin-default-unit's main functionalities?

Automatic unit appending

Automatically appends 'px' to numeric values for properties that typically require a pixel unit, while leaving unitless values as is for properties that do not require units.

{
  container: {
    width: 100, // becomes '100px' automatically
    opacity: 0.5 // remains unitless as expected
  }
}

Customizable unit mapping

Allows customization of the units appended to specific properties, enabling developers to specify alternative units like 'em' or 'rem' for properties like 'line-height' and 'font-size'.

jss.use(defaultUnit({
  'line-height': 'em',
  'font-size': 'rem'
}));

Other packages similar to jss-plugin-default-unit

Keywords

cssinjs

FAQs

Package last updated on 09 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts